<template>
  <div class="page">
    <div class="title">我的客户</div>
    <div class="searchContent">
      <div class="inputContent">
        <ui-form class="query-form" :model="queryForm" label-width="140px">
          <ui-form-item label="客户类型">
            <ui-select placeholder="请选择客户类型" v-model="queryForm.customType" @change="getCustomLevel">
              <ui-option v-for="(item, index) in customTypeList" :key="index" :value="item.id" :label="item.name"></ui-option>
            </ui-select>
          </ui-form-item>
          <ui-form-item label="管理类型">
            <ui-select placeholder="请选择管理类型" v-model="queryForm.manageType">
              <ui-option v-for="(item, index) in manageTypeList" :key="index" :value="item.id" :label="item.name"></ui-option>
            </ui-select>
          </ui-form-item>
          <ui-form-item label="客户等级">
            <ui-select placeholder="请选择客户等级" v-model="queryForm.customLevel" :disabled="queryForm.customType == 1">
              <ui-option v-for="(item, index) in customLevelList" :key="index" :value="item.id" :label="item.name"></ui-option>
            </ui-select>
          </ui-form-item>
          <ui-form-item label="是否关注">
            <ui-select placeholder="请选择是否关注" v-model="queryForm.isConcern">
              <ui-option v-for="(item, index) in isConcernList" :key="index" :value="item.id" :label="item.name"></ui-option>
            </ui-select>
          </ui-form-item>
          <ui-form-item label="是否建立亲缘关系">
            <ui-select placeholder="请选择是否建立亲缘关系" v-model="queryForm.setRelation">
              <ui-option v-for="(item, index) in setRelationList" :key="index" :value="item.id" :label="item.name"></ui-option>
            </ui-select>
          </ui-form-item>
          <ui-form-item label="客户名称">
            <ui-input type="text" placeholder="请输入客户名称" v-model="queryForm.customName"> </ui-input>
          </ui-form-item>
          <ui-form-item label="证件号码">
            <ui-input type="text" placeholder="请输入证件号码" v-model="queryForm.idNumber"> </ui-input>
          </ui-form-item>
          <ui-form-item label="联系电话">
            <ui-input type="text" placeholder="请输入联系电话" v-model="queryForm.phone"> </ui-input>
          </ui-form-item>
        </ui-form>
      </div>
      <div class="searchButton">
        <ui-button class="default-btn reset" @click="reset">重置</ui-button>
        <ui-button class="primary-btn" @click="search">查询</ui-button>
      </div>
    </div>
    <div class="tableContent">
      <div class="name">客户列表</div>
      <vx-nodata :list="tableData" v-loading="isLoading" sub-title="暂无数据">
        <vx-table-slot :tableData="tableData" :columns="columns" @multipleSelection="multipleSelection" :isSelect="true">
          <template #action="{ scope }">
            <ui-button icon="ui-icon-star-on" @click="concern(scope.row)" class="concern" v-if="scope.row.isConcern == 0">关注</ui-button>
            <ui-button class="alreayConcern" v-else @click="cancelConcern(scope.row)">已关注</ui-button>
          </template>
        </vx-table-slot>
        <ui-pagination
          :total="total"
          :page-size="pageSize"
          :current-page="currentPage"
          :layout="layout"
          :page-sizes="pageSizeList"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          background
        >
        </ui-pagination>
      </vx-nodata>
      <div class="footerButton">
        <ui-button class="primary-btn" @click="customTransfer" :disabled="customSelection.length < 1">客户移交</ui-button>
        <ui-button class="primary-btn" @click="setRelationship" :disabled="customSelection.length < 1">建立亲缘关系</ui-button>
        <ui-button class="primary-btn" @click="cancelRelationship" :disabled="customSelection.length < 1">解除亲缘关系</ui-button>
      </div>
    </div>
  </div>
</template>

<script>
import pagination from '@/common/mixin/pagination.js'; // 混入/分页
import vxTableSlot from '@/components/vx-table-slot';
export default {
  name: 'myCustom',
  mixins: [pagination],
  components: {
    vxTableSlot,
  },
  data() {
    return {
      queryForm: {},
      customTypeList: [
        { id: 1, name: '全部' },
        { id: 2, name: '类型一' },
        { id: 3, name: '类型二' },
      ],
      manageTypeList: [
        { id: 1, name: '类型一' },
        { id: 2, name: '类型二' },
      ],
      customLevelList: [
        { id: 1, name: '类型一' },
        { id: 2, name: '类型二' },
      ],
      setRelationList: [
        { id: 1, name: '类型一' },
        { id: 2, name: '类型二' },
      ],
      isConcernList: [
        { id: 1, name: '是' },
        { id: 2, name: '否' },
      ],
      tableData: [
        { customName: '1111111111', isConcern: 0 },
        { customName: '1111111111', isConcern: 0 },
        { customName: '1111111111', isConcern: 1 },
      ],
      columns: [
        {
          label: '客户名称',
          prop: 'customName',
          width: '200',
        },
        {
          label: '客户类型',
          prop: 'customType',
          width: '200',
        },
        {
          label: '联系电话',
          prop: 'phone',
          width: '200',
        },
        {
          label: '证件类型',
          prop: 'documentType',
          width: '200',
        },
        {
          label: '证件号码',
          prop: 'documentNumber',
          width: '200',
        },
        {
          label: '管护机构',
          prop: 'householdManagementInstitution',
          width: '200',
        },
        {
          label: '管理类型',
          prop: 'manageType',
          width: '200',
        },
        {
          label: '金融资产',
          prop: 'financialAssets',
          width: '200',
        },
        {
          label: '客户等级',
          prop: 'financialAssets',
          formatter: (row, column, cellValue, index) => {
            return row.customLevel;
          },
          width: '200',
        },
        {
          label: '亲缘关系',
          prop: 'setRelation',
          width: '200',
        },
        {
          label: '操作',
          prop: 'slot',
          slots: { name: 'action' },
          width: '200',
          fixed: 'right',
        },
      ],
      customSelection: [],
      isLoading: false,
      total:10,
      pageSize:1,
      currentPage:1,
      pageSizeList:[5,10,20]
    };
  },
  mounted() {
    this.searchList();
  },
  methods: {
    searchList() {},
    // handleSelectionChange(val) {
    //   this.customSelection = val;
    // },
    getCustomLevel(e) {},
    search() {
      this.pageNum = 1;
      this.searchList();
    },
    reset() {
      this.queryForm.customName = undefined;
      this.queryForm.manageType = undefined;
      this.queryForm.customLevel = undefined;
      this.queryForm.customType = undefined;
      this.queryForm.isConcern = undefined;
      this.queryForm.setRelation = undefined;
      this.queryForm.idNumber = undefined;
      this.queryForm.phone = undefined;
      this.searchList();
    },
    concern(e) {},
    cancelConcern(e) {},
    customTransfer() {
      this.$router.push({
        path: '/customManager/myCustom/customTransfer/customTransferEnt',
        query: {
          customData: this.customSelection,
        },
      });
    },
    setRelationship() {
      this.$router.push({
        path: '/customManager/myCustom/setRelation/setRelationEnt',
        query: {
          customData: this.customSelection,
        },
      });
    },
    cancelRelationship() {
      this.$router.push({
        path: '/customManager/myCustom/removeRelation/removeRelationEnt',
        query: {
          customData: this.customSelection,
        },
      });
    },
    multipleSelection(val) {
      //多选选中数据
      this.customSelection = val;
    },
  },
};
</script>

<style lang="scss" scoped>
.page {
  .title {
    font-size: 18px;
    color: #000;
    font-weight: bold;
  }
  .searchContent {
    background: #fff;
    padding: 20px 20px 0 0;
    margin-top: 10px;
    .inputContent {
      display: flex;
      align-items: center;
      flex-wrap: wrap;
      padding: 10px;
      ::v-deep .ui-input {
        width: 190px !important;
      }
      ::v-deep .query-form .ui-form-item {
        width: 23% !important;
      }
    }
    .searchButton {
      padding: 10px 10px 10px 10px;
      display: flex;
      justify-content: right;
      align-items: center;
      .reset {
        border-color: #5085f9;
        color: #5085f9;
      }
    }
  }
  .tableContent {
    margin-top: 20px;
    background: #fff;
    padding: 20px;
    .name {
      font-size: 14px;
      color: #000;
      margin-bottom: 20px;
      font-weight: bold;
    }
    .concern {
      background: #fff;
      border-color: orange;
      color: orange;
      font-size: 14px;
    }
    .alreayConcern {
      background: #fff;
      border-color: #ccc;
      font-size: 14px;
    }
    .footerButton {
      border-top: 1px solid #ccc;
      margin-top: 20px;
      padding: 20px;
      display: flex;
      align-items: center;
      justify-content: center;
    }
  }
}
.query-form {
  display: flex;
  flex-wrap: wrap;
}
</style>
